package com.wench.spring5.test_demo;

import com.wench.spring5.Book;
import com.wench.spring5.Order;
import com.wench.spring5.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author epro
 * @date 2021/12/30 13:53
 */
public class Spring5Test {

    private final ApplicationContext appContext = new ClassPathXmlApplicationContext("bean1.xml");

    @Test
    public void testAdd() {
        // 1、加载Spring配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
        // 2、获取配置创建的对象
        User user = context.getBean("user", User.class);
        System.out.println(user);
        user.add();
    }

    @Test
    public void testBook01() {
        Book book = appContext.getBean("book", Book.class);
        System.out.println(book);
    }

    @Test
    public void testBook02() {
        Book book = appContext.getBean("book02", Book.class);
        System.out.println(book);
    }

    @Test
    public void testOrder() {
        Order order = appContext.getBean("order", Order.class);
        System.out.println(order);
    }
}
